<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: RCapture::Interceptable [RDoc Documentation]</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;

    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }

  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )

  // ]]>
  </script>

</head>
<body>


    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">RCapture::Interceptable</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>


                <a href="../../files/rcapture/interceptable_rb.html">

                rcapture/interceptable.rb

                </a>


        <br />

            </td>
        </tr>


        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">

  <div id="contextContent">

    <div id="description">
      <h1>Introduction</h1>
<p>
<a href="Interceptable.html">Interceptable</a> is a module mixin to enrich
the receiver with capturing capatibilities.
</p>
<p>
It can be used at a class scope:
</p>
<pre>
 class Array
   include RCapture::Interceptable
 end
</pre>
<p>
This will provide the methods <tt>capture</tt>, <tt><a
href="Interceptable.html#M000004">capture_pre</a></tt>, and <tt><a
href="Interceptable.html#M000002">capture_post</a></tt>. at class and
instance level:
</p>
<pre>
 Array.capture :methods =&gt; :push do
   puts 'pushed'
 end
</pre>
<p>
will affect all instances of Array. On the other hand
</p>
<pre>
 a = []
 a.capture :methods =&gt; :push do
   puts 'pushed'
 end
</pre>
<p>
will affect only the instance <tt>a</tt>.
</p>
<p>
Instances can be extended by <a href="Interceptable.html">Interceptable</a>
to provide capturing capatibilities for the selected instance only:
</p>
<pre>
 a = []
 a.extend(RCapture::Interceptable)
 a.capture :methods =&gt; :push do
   puts 'pushed'
 end
</pre>

    </div>

   </div>


    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">

        <a href="#M000003">capture</a>&nbsp;&nbsp;

        <a href="#M000002">capture_post</a>&nbsp;&nbsp;

        <a href="#M000004">capture_pre</a>&nbsp;&nbsp;

      </div>
    </div>

  </div>

    <!-- if includes -->

    <div id="section">




    <!-- if method_list -->

    <div id="methods">

      <h3 class="section-bar">Public Instance methods</h3>


      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">

          <span class="method-name">capture</span><span class="method-args">(args, &amp;callback)</span>

        </div>

        <div class="method-description">

          <p>
Alias for <a href="Interceptable.html#M000002">capture_post</a>
</p>

        </div>
      </div>


      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">

          <a href="#M000002" class="method-signature">

          <span class="method-name">capture_post</span><span class="method-args">(args, &amp;callback)</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Perform a post-capture on the given class/instance.
</p>
<h3>Arguments</h3>
<table>
<tr><td valign="top">args:</td><td>A hash of options. The following are recognized

<dl>
<dt>:methods</dt><dd>Instance methods to capture. Either a single method name/symbol or and
array of names/symbols.

</dd>
<dt>:class_methods</dt><dd>Class methods to capture. Either a single method name/symbol or and array
of names/symbols.

</dd>
</dl>
</td></tr>
<tr><td valign="top">callback:</td><td>The block to be invoked after captured method was invoked. The callback
will be given an instance of <a href="CapturedInfo.html">CapturedInfo</a>.

</td></tr>
</table>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/interceptable.rb, line 64</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">capture_post</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>)
      <span class="ruby-constant">RCapture</span><span class="ruby-operator">::</span><span class="ruby-constant">Internal</span>.<span class="ruby-identifier">capture_post</span>(
        <span class="ruby-constant">RCapture</span><span class="ruby-operator">::</span><span class="ruby-constant">Internal</span>.<span class="ruby-identifier">singleton_class</span>(<span class="ruby-keyword kw">self</span>), 
        <span class="ruby-identifier">args</span>, 
        <span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>
      )
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">

          <a href="#M000004" class="method-signature">

          <span class="method-name">capture_pre</span><span class="method-args">(args, &amp;callback)</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Perform a pre-capture on the given class/instance.
</p>
<h3>Arguments</h3>
<table>
<tr><td valign="top">args:</td><td>A hash of options. The following are recognized

<dl>
<dt>:methods</dt><dd>Instance methods to capture. Either a single method name/symbol or and
array of names/symbols.

</dd>
<dt>:class_methods</dt><dd>Class methods to capture. Either a single method name/symbol or and array
of names/symbols.

</dd>
</dl>
</td></tr>
<tr><td valign="top">callback:</td><td>The block to be invoked before the captured method is invoked. The callback
will be given an instance of <a href="CapturedInfo.html">CapturedInfo</a>.

</td></tr>
</table>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
<span class="ruby-comment cmt"># File rcapture/interceptable.rb, line 83</span>
    <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">capture_pre</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>)
      <span class="ruby-constant">RCapture</span><span class="ruby-operator">::</span><span class="ruby-constant">Internal</span>.<span class="ruby-identifier">capture_pre</span>(
        <span class="ruby-constant">RCapture</span><span class="ruby-operator">::</span><span class="ruby-constant">Internal</span>.<span class="ruby-identifier">singleton_class</span>(<span class="ruby-keyword kw">self</span>), 
        <span class="ruby-identifier">args</span>, 
        <span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>
      )
    <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>



    </div>




  </div>

<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>
